<template>
  <form>
    <label for="username">用户名：</label><br />
    <input type="text" name="username" v-model="username" id="username" /><br />
    <label for="password">密码：</label><br />
    <input type="password" v-model="password" name="pwd" id="password" /><br />
    <input type="button" value="注册" @click="submitF"/>
  </form>
</template>

<script>
export default {
    data() {
        return {
            username:"",
            password:""
        }
    },
    methods:{
        submitF:function (){
            let url = "/registerServlet";
            let params= `username=${this.username}&password=${this.password}`;

            this.$axios.post(url, params).then(resp => {
                if(resp.data){
                    alert("注册成功");
                    location.href="#/friend";
                } else {
                    alert("该用户名已存在！");
                }
            });
        }
    }
};
</script>

<style>
</style>